/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 * LocalValidationCase.java
 * 
 *                                   Revision History
 * -----------------------------------------------------------------------------------------
 * Author                    Date            CR        Comments
 * ----------------------|------------|--------------|--------------------------------------
 * pcmnac                  2007.10.27                  Initial version.
 * 
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

package com.google.code.localvalidator;

/**
 * Represents a validation case, which has the success condition, the error message and the class of exception
 * which will be thrown case validation fails.
 * 
 * @author pcmnac@gmail.com
 * 
 */
public class LocalValidationCase
{
  // ===========================================================================================================
  // Public API.
  // ===========================================================================================================

  /**
   * Constructor
   * 
   * @param successCondition
   *          Initial value for {@link #successCondition}.
   * @param exceptionArguments
   *          Initial value for {@link #exceptionArguments}.
   * @param exceptionClass
   *          Initial value for {@link #exceptionClass}.
   */
  public LocalValidationCase(boolean successCondition, Class<? extends RuntimeException> exceptionClass,
      Object... exceptionArguments)
  {
    this.successCondition = successCondition;
    this.exceptionArguments = exceptionArguments;
    this.exceptionClass = exceptionClass;
  }

  /**
   * Constructor
   * 
   * Calls {@link #LocalValidationCase(boolean, Class, Object...)} passing <code>null</code> to exceptionClass.
   * 
   */
  public LocalValidationCase(boolean successCondition, String exceptionMessage)
  {
    this(successCondition, null, exceptionMessage);
  }

  /**
   * Constructor
   * 
   * Calls {@link #LocalValidationCase(boolean, Class, Object...)} passing <code>null</code> to exceptionClass.
   * 
   */
  public LocalValidationCase(boolean successCondition, RuntimeException exception)
  {
    this.successCondition = successCondition;
    this.exception = exception;
  }

  /**
   * Constructor
   * 
   * Calls {@link #LocalValidationCase(boolean, Class, Object[])} passing <code>null</code> to exceptionArguments
   * and exceptionClass.
   * 
   */
  public LocalValidationCase(boolean successCondition)
  {
    this(successCondition, (RuntimeException) null);
  }

  /**
   * Getter for {@link #successCondition}.
   * 
   * @return Value of {@link #successCondition}.
   */
  public boolean isSuccessCondition()
  {
    return successCondition;
  }

  /**
   * Setter for {@link #successCondition}.
   * 
   * @param successCondition
   *          New value for {@link #successCondition}.
   */
  public void setSuccessCondition(boolean successCondition)
  {
    this.successCondition = successCondition;
  }

  /**
   * Getter for {@link #exceptionClass}.
   * 
   * @return Value of {@link #exceptionClass}.
   */
  public Class<? extends RuntimeException> getExceptionClass()
  {
    return exceptionClass;
  }

  /**
   * Setter for {@link #exceptionClass}.
   * 
   * @param exceptionClass
   *          New value for {@link #exceptionClass}.
   */
  public void setExceptionClass(Class<? extends RuntimeException> exceptionClass)
  {
    this.exceptionClass = exceptionClass;
  }

  /**
   * Getter for {@link #exceptionArguments}.
   * 
   * @return Value of {@link #exceptionArguments}.
   */
  public Object[] getExceptionArguments()
  {
    return exceptionArguments;
  }

  /**
   * Setter for {@link #exceptionArguments}.
   * 
   * @param exceptionArguments
   *          New value for {@link #exceptionArguments}.
   */
  public void setExceptionArguments(Object[] exceptionArguments)
  {
    this.exceptionArguments = exceptionArguments;
  }

  /**
   * Getter for {@link #exception}.
   * 
   * @return Value of {@link #exception}.
   */
  public RuntimeException getException()
  {
    return exception;
  }

  /**
   * Setter for {@link #exception}.
   * 
   * @param exception
   *          New value for {@link #exception}.
   */
  public void setException(RuntimeException exception)
  {
    this.exception = exception;
  }

  // ===========================================================================================================
  // Protected members.
  // ===========================================================================================================

  // ===========================================================================================================
  // Package members.
  // ===========================================================================================================

  // ===========================================================================================================
  // Private members.
  // ===========================================================================================================

  /**
   * The validation success condition.
   */
  private boolean successCondition;

  /**
   * The exception which will be thrown case validation fails.
   */
  private RuntimeException exception;

  /**
   * The class of exception which will be thrown case validation fails.
   */
  private Class<? extends RuntimeException> exceptionClass;

  /**
   * The exception arguments.
   */
  private Object[] exceptionArguments;

}
